package com.demo2do.fms.queue.entity;

import java.math.BigDecimal;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * FMS-VAM车辆同步表
 *
 * @author Ark
 *
 */
public class RemoteVehicle {

    /** vam车辆id */
    private Long vamId;
    
    /** 
     * 资产分类代码
     * 
     *  A01 - 牵引车
     *  A02 - 挂车
     *  A03 - 救援车
     */
    private String vehicleCls;
    
    /** 车辆使用公司 / 所属运输公司 */
    private Long organizationId;
    
    /** 产证所有者 */
    private String floorLord;

    /** 中文车牌号 */
    private String brandCnCode;
    
    /** VIN码 */
    private String vincode;
    
    /** 品牌 */
    private String brand;

    /** 轴数 */
    private BigDecimal axles;

    /** 装载量 */
    private BigDecimal trainload;
    
    /** 年检有效期 */
    private Date annualInspectionDate;
    
    /** 车辆类型（行驶证） */
    private String vehicleType;

    /** 资产状态 */
    private String assetStatus;
    
    /** 行驶证 */
    private String drivingLicense;

    /** 行驶证附件 */
    private String drivingLicenseCopy;

    /** 45度角照片 */
    private String vehiclePhoto;
    
    
    
    
    // ===================== 牵引车字段  =======================
    

    /** 英文车牌号 */
    private String brandEnCode;

    /** 车辆所属权 */
    private String carOwnership;
    
    /** 运输工具类型 */
    private String transMean;
    
    /** 牵引车马力 */
    private BigDecimal horsepower;
    
    /** 发证日期 */
    private Date issuingTime;
    
    /** 注册日期 */
    private Date registrationTime;
    
    /** gps品牌 */
    private String gps;
    
    /** gps绑定SIM卡号 */
    private String simCard;
    
    /** 购车合同 */
    private String vehicleContact;
    
    
    
    
    
    // ===================== 挂车字段  =======================
    
    
    /** 挂车类型 */
    private String trailerType;
    
    /** 挂车长 */
    private BigDecimal length;
    
    /** 挂车宽 */
    private BigDecimal width;
    
    /** 挂车高 */
    private BigDecimal height;
    

    
    /** 创建人 */
    private Long creator;
    
    /** 创建时间 */
    private Date createTime;
    
    /** 最后修改人 */
    private Long lastOperator;
    
    /** 最后修改时间 */
    private Date lastModifyTime;
    
    private Boolean disabled;
    
    /**
     * The default construct
     */
    public RemoteVehicle() {
    }
    
    /**
     * 是否有效资产
     * 
     * @return
     */
    public boolean validVehicleCls() {
        return isTractor() || isTrailer() || isRescue();
    }
    
    /**
     * 是否是牵引车
     * 
     * @return
     */
    @JsonIgnore
    public boolean isTractor() {
        return StringUtils.equals("A01", vehicleCls);
    }
    
    /**
     * 是否是挂车
     * 
     * @return
     */
    @JsonIgnore
    public boolean isTrailer() {
        return StringUtils.equals("A02", vehicleCls);
    }
    
    /**
     * 是否是救援车
     * 
     * @return
     */
    @JsonIgnore
    public boolean isRescue() {
        return StringUtils.equals("A03", vehicleCls);
    }
    
    /**
     * 校验公共必填项
     * 
     * @return
     */
    public String validCommonRequired() {
        
        if (vamId == null) {
            return "车辆id不能为空";
        } else if (organizationId == null) {
            return "车辆使用方不能为空";
        } else if (StringUtils.isBlank(floorLord)) {    
            return "产证所有者不能为空";
        } else if (StringUtils.isBlank(brandCnCode)) {
            return "车辆中文车牌号不能为空";
        } else if (StringUtils.isBlank(vincode)) {
            return "VIN码不能为空";
        } else if (StringUtils.isBlank(brand)) {
            return "品牌不能为空";
        } else if (axles == null) {
            return "轴数不能为空";
        } else if (trainload == null) {
            return "装载量不能为空";
        } else if (annualInspectionDate == null) {
            return "年检有效期至不能为空";
        } else if (StringUtils.isBlank(vehicleType)) {
            return "车辆类型（行驶证）不能为空";
        } else if (StringUtils.isBlank(assetStatus)) {
            return "资产状态不能为空";
        } else if (StringUtils.isBlank(drivingLicense)) {
            return "行驶证不能为空";
        } else if (StringUtils.isBlank(drivingLicenseCopy)) {
            return "行驶证副本不能为空";
        } else if (StringUtils.isBlank(vehiclePhoto)) {
            return "45度角照片不能为空";
        } else if (creator == null) {
            return "创建人不能为空";
        }
        
        return null;
        
    }
    
    /**
     * 校验牵引车必填项
     * 
     * @return
     */
    public String validTractorRequired() {
        
        String commonRequired = this.validCommonRequired();
        if (StringUtils.isNotBlank(commonRequired)) {
            return commonRequired;
        }
        
        if (StringUtils.isBlank(brandEnCode)) {
            return "车辆英文车牌号不能为空";
        } else if (StringUtils.isBlank(carOwnership)) {
            return "车辆所属权不能为空";
        } else if (StringUtils.isBlank(transMean)) {
            return "运输工具类型不能为空";
        } else if (horsepower == null) {
            return "牵引车马力不能为空";
        } else if (issuingTime == null) {
            return "发证时间不能为空";
        } else if (registrationTime == null) {
            return "注册时间不能为空";
        } 
        
        return null;
    }
    
    /**
     * 校验挂车必填项
     * 
     * @return
     */
    public String validTrailerRequired() {
        
        String commonRequired = this.validCommonRequired();
        if (StringUtils.isNotBlank(commonRequired)) {
            return commonRequired;
        }
        
        if (trailerType == null) {
            return "挂车类型不能为空";
        } else if (length == null || width == null || height == null) {
            return "挂车长宽高不能为空";
        }
        
        return null;
        
    }
    
    /**
     * @return
     */
    public RemoteVehicle disabled() {
        this.disabled = false;
        return this;
    }

    /**
     * @return
     */
    public Long getVamId() {
        return vamId;
    }

    /**
     * @return the vehicleCls
     */
    public String getVehicleCls() {
        return vehicleCls;
    }
    
    /**
     * @return
     */
    public Long getOrganizationId() {
        return organizationId;
    }

    /**
     * @return the floorLord
     */
    public String getFloorLord() {
        return floorLord;
    }

    /**
     * @return the brandCnCode
     */
    public String getBrandCnCode() {
        return brandCnCode;
    }

    /**
     * @return the vincode
     */
    public String getVincode() {
        return vincode;
    }

    /**
     * @return the brand
     */
    public String getBrand() {
        return brand;
    }

    /**
     * @return the axles
     */
    public BigDecimal getAxles() {
        return axles;
    }

    /**
     * @return the trainload
     */
    public BigDecimal getTrainload() {
        return trainload;
    }

    /**
     * @return the annualInspectionDate
     */
    public Date getAnnualInspectionDate() {
        return annualInspectionDate;
    }

    /**
     * @return the vehicleType
     */
    public String getVehicleType() {
        return vehicleType;
    }

    /**
     * @return the assetStatus
     */
    public String getAssetStatus() {
        return assetStatus;
    }

    /**
     * @return the drivingLicense
     */
    public String getDrivingLicense() {
        return drivingLicense;
    }

    /**
     * @return the drivingLicenseCopy
     */
    public String getDrivingLicenseCopy() {
        return drivingLicenseCopy;
    }

    /**
     * @return the vehiclePhoto
     */
    public String getVehiclePhoto() {
        return vehiclePhoto;
    }

    /**
     * @return the brandEnCode
     */
    public String getBrandEnCode() {
        return brandEnCode;
    }

    /**
     * @return the carOwnership
     */
    public String getCarOwnership() {
        return carOwnership;
    }

    /**
     * @return the transMean
     */
    public String getTransMean() {
        return transMean;
    }

    /**
     * @return the horsepower
     */
    public BigDecimal getHorsepower() {
        return horsepower;
    }

    /**
     * @return the issuingTime
     */
    public Date getIssuingTime() {
        return issuingTime;
    }

    /**
     * @return the registrationTime
     */
    public Date getRegistrationTime() {
        return registrationTime;
    }

    /**
     * @return the gps
     */
    public String getGps() {
        return gps;
    }

    /**
     * @return
     */
    public String getSimCard() {
        return simCard;
    }

    /**
     * @return the vehicleContact
     */
    public String getVehicleContact() {
        return vehicleContact;
    }

    /**
     * @return the trailerType
     */
    public String getTrailerType() {
        return trailerType;
    }

    /**
     * @return the length
     */
    public BigDecimal getLength() {
        return length;
    }

    /**
     * @return the width
     */
    public BigDecimal getWidth() {
        return width;
    }

    /**
     * @return the height
     */
    public BigDecimal getHeight() {
        return height;
    }

    /**
     * @return
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @return the lastModifyTime
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }
    
    /**
     * @return
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @param vamId
     */
    public void setVamId(Long vamId) {
        this.vamId = vamId;
    }

    /**
     * @param vehicleCls the vehicleCls to set
     */
    public void setVehicleCls(String vehicleCls) {
        this.vehicleCls = vehicleCls;
    }
    
    /**
     * @param organizationId
     */
    public void setOrganizationId(Long organizationId) {
        this.organizationId = organizationId;
    }

    /**
     * @param floorLord the floorLord to set
     */
    public void setFloorLord(String floorLord) {
        this.floorLord = floorLord;
    }

    /**
     * @param brandCnCode the brandCnCode to set
     */
    public void setBrandCnCode(String brandCnCode) {
        this.brandCnCode = brandCnCode;
    }

    /**
     * @param vincode the vincode to set
     */
    public void setVincode(String vincode) {
        this.vincode = vincode;
    }

    /**
     * @param brand the brand to set
     */
    public void setBrand(String brand) {
        this.brand = brand;
    }

    /**
     * @param axles the axles to set
     */
    public void setAxles(BigDecimal axles) {
        this.axles = axles;
    }

    /**
     * @param trainload the trainload to set
     */
    public void setTrainload(BigDecimal trainload) {
        this.trainload = trainload;
    }

    /**
     * @param annualInspectionDate the annualInspectionDate to set
     */
    public void setAnnualInspectionDate(Date annualInspectionDate) {
        this.annualInspectionDate = annualInspectionDate;
    }

    /**
     * @param vehicleType the vehicleType to set
     */
    public void setVehicleType(String vehicleType) {
        this.vehicleType = vehicleType;
    }

    /**
     * @param assetStatus the assetStatus to set
     */
    public void setAssetStatus(String assetStatus) {
        this.assetStatus = assetStatus;
    }

    /**
     * @param drivingLicense the drivingLicense to set
     */
    public void setDrivingLicense(String drivingLicense) {
        this.drivingLicense = drivingLicense;
    }

    /**
     * @param drivingLicenseCopy the drivingLicenseCopy to set
     */
    public void setDrivingLicenseCopy(String drivingLicenseCopy) {
        this.drivingLicenseCopy = drivingLicenseCopy;
    }

    /**
     * @param vehiclePhoto the vehiclePhoto to set
     */
    public void setVehiclePhoto(String vehiclePhoto) {
        this.vehiclePhoto = vehiclePhoto;
    }

    /**
     * @param brandEnCode the brandEnCode to set
     */
    public void setBrandEnCode(String brandEnCode) {
        this.brandEnCode = brandEnCode;
    }

    /**
     * @param carOwnership the carOwnership to set
     */
    public void setCarOwnership(String carOwnership) {
        this.carOwnership = carOwnership;
    }

    /**
     * @param transMean the transMean to set
     */
    public void setTransMean(String transMean) {
        this.transMean = transMean;
    }

    /**
     * @param horsepower the horsepower to set
     */
    public void setHorsepower(BigDecimal horsepower) {
        this.horsepower = horsepower;
    }

    /**
     * @param issuingTime the issuingTime to set
     */
    public void setIssuingTime(Date issuingTime) {
        this.issuingTime = issuingTime;
    }

    /**
     * @param registrationTime the registrationTime to set
     */
    public void setRegistrationTime(Date registrationTime) {
        this.registrationTime = registrationTime;
    }

    /**
     * @param gps the gps to set
     */
    public void setGps(String gps) {
        this.gps = gps;
    }

    /**
     * @param simCard
     */
    public void setSimCard(String simCard) {
        this.simCard = simCard;
    }

    /**
     * @param vehicleContact the vehicleContact to set
     */
    public void setVehicleContact(String vehicleContact) {
        this.vehicleContact = vehicleContact;
    }

    /**
     * @param trailerType the trailerType to set
     */
    public void setTrailerType(String trailerType) {
        this.trailerType = trailerType;
    }

    /**
     * @param length the length to set
     */
    public void setLength(BigDecimal length) {
        this.length = length;
    }

    /**
     * @param width the width to set
     */
    public void setWidth(BigDecimal width) {
        this.width = width;
    }

    /**
     * @param height the height to set
     */
    public void setHeight(BigDecimal height) {
        this.height = height;
    }

    /**
     * @param creator
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param lastOperator
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }

    /**
     * @param lastModifyTime the lastModifyTime to set
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }
    
    /**
     * @param disabled
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }
    
}
